package com.itcast.dao;

import com.itcast.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmpDao {
    /**
     * 查询所有员工
     * @return
     */
    @Select("select * from emp")
    public List<Emp> findAll();




    /**
     * 根据id查询员工
     * @param id
     * @return
     */
    @Select("select * from emp where id=#{id}")
    public Emp findById(String id);
    /**
     * 添加员工
     * @param emp
     */
    @Insert("insert into emp values(#{id},#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entry_date},#{create_time},#{update_time})")
    public void adddate(Emp emp);
    /**
     * 删除员工
     * @param id
     */
    @Delete("delete from emp where id=#{id}")
    public void delete(String id);
    /**
     * 修改员工
     * @param emp
     * 当属性是对象类型时#{字段名}
     */
    @Update("update emp set username=#{username},password=#{password},name=#{name},gender=#{gender},phone=#{phone},job=#{job},salary=#{salary},image=#{image},entry_date=#{entry_date},create_time=#{create_time},update_time=#{update_time} where id=#{id}")
    public void update(Emp emp);
    /**
     * 按照员工的入职时间区间进行查询
     * @param start
     * @param end
     * 当属性是对象并且有多个属性时，需要使用@Param指定参数名称
     */
    @Select("select * from emp where entry_date between #{start} and #{end}")
    public List<Emp> findByEntryDate(@Param(value = "start")String start, @Param(value = "end") String end);

    public List<Emp> findByIds(@Param(value = "ids") String[] ids);
}
